//
//  AsyncCacheImageView.h
//  ymall
//
//  Created by yuike6 yuike6 on 12-2-8.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "DownloadHelper.h"
//#import "DownloadRecvData.h"
//#import "header.h"

@protocol AsyncImageCacheViewDelegate;
@class DownloadHelper;
@class DownloadRecvData;
@class ImageSpinner;

@interface AsyncCacheImageView : UIImageView<DownloadHelperDelegate>
{
    UIActivityIndicatorView * indicator;
    
    NSURL   * currentUrl;
    id<AsyncImageCacheViewDelegate> delegate;
    
    DownloadHelper * downLoaderHelper_;
    DownloadRecvData * recvData_;
    
    ImageSpinner * spinner_;
    BOOL bDefaultWaitingControl;
}

@property (nonatomic, retain) NSURL* currentUrl;
@property (nonatomic, assign) id<AsyncImageCacheViewDelegate> delegate;

@property (nonatomic, retain) DownloadHelper * downLoaderHelper;
@property (nonatomic, retain) DownloadRecvData * recvData;

@property (nonatomic, retain) ImageSpinner * spinner;

- (BOOL)loadImageWithURL:(NSURL*)url 
			  parameters:(NSDictionary*)params 
  additionalHeaderFields:(NSDictionary*)headerFields 
		 timeoutInterval:(NSTimeInterval)timeout;

- (BOOL)loadImageWithURLString:(NSString*)urlString
					parameters:(NSDictionary*)params 
		additionalHeaderFields:(NSDictionary*)headerFields 
			   timeoutInterval:(NSTimeInterval)timeout;

@end


@protocol AsyncImageCacheViewDelegate

- (void)asyncImageView:(AsyncCacheImageView*)asyncImageView didReceiveImage:(UIImage*)image imageUrl:(NSURL*)url;
- (void)asyncImageViewFailed:(AsyncCacheImageView*)asyncImageView imageUrl:(NSURL*)url;

@end